package com.aliengen.thingple.driverapp.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import com.aliengen.thingple.driverapp.network.DataSyncAdapter;

/**
 * This class is part of the Thingple mobile application for the CMC168 Handheld reader.
 *
 * Copyright AlienGen Limited 2016. All rights reserved.
 *
 * @author Timothé Mermet-Buffet <tim@aliengen.com>
 */
public class SyncService extends Service {
    private static final Object sSyncAdapterLock = new Object();
    private static DataSyncAdapter sSyncAdapter = null;

    @Override
    public void onCreate() {
        synchronized (sSyncAdapterLock) {
            if (sSyncAdapter == null)
                sSyncAdapter = new DataSyncAdapter(getApplicationContext(), true);
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return sSyncAdapter.getSyncAdapterBinder();
    }
}
